<template>
 <section v-loading="loading" class="batch-data">
    <h2>补充单项数据</h2>
    <el-form
    ref="ruleFormRef"
    :model="ruleForm"
    :rules="rules"
    label-width="auto"
    :inline="true"
  >
    <el-form-item label="数据日期：" prop="certainDate">
      <el-date-picker
        v-model="ruleForm.certainDate"
        type="daterange"
        clearable
        :editable="false"
        placeholder="请选择数据日期"
        format="YYYY-MM-DD"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="YYYY-MM-DD"
        :disabled-date="disabledDate"
        @calendar-change="calendarChange"
      />
    </el-form-item>
    <el-form-item label="数据类型：" prop="reqTypeList">
      <el-select
        v-model="ruleForm.reqCodeList" 
        multiple
        placeholder="请选择数据类型"
      >
        <el-option 
          v-for="item in allSingleDataTypes" 
          :key="item.value"
          :label="item.label" 
          :value="item.value" 
        >
        <div style="display:inline-block;border-top: 1px solid skyblue;width: 100%;">
          <span style="display:inline-block;min-width: 38px;">{{ item.label1 }}</span>
          <span style="display:inline-block;min-width: 185px;">{{ item.label2 }}</span>
          <span style="display:inline-block;min-width: 60px;">{{ item.label3 }}</span>
        </div>
      </el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="验证码：" prop="uniqueCode">
      <el-input v-model.trim="ruleForm.uniqueCode" type="password" placeholder="请输入验证码" />
    </el-form-item>
    <el-form-item>
      <el-button @click="resetForm">重置</el-button>
      <el-button type="primary" @click="submitForm">获取</el-button>
    </el-form-item>
  </el-form>
  <div class="req-history">
    <h5>获取记录(不一定成功)::</h5>
    <div class="req-history__item" v-for="item in reqHistory" :key="item.certainDate + Math.random()">
      <div>数据日期：<span>{{ item.certainDate }}</span></div>
      <div>数据类型：<span>{{ item.reqTypes }}</span></div>
    </div>
  </div>
  </section>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import {useBatchData} from '.'

const ruleFormRef = ref(null)

const {
    loading,

    ruleForm,
    rules,
    submitForm,
    resetForm,
    reqHistory,
    disabledDate,
    calendarChange,

    allSingleDataTypes
  } = useBatchData(ruleFormRef)
</script>

<style lang="scss" scoped>
.batch-data {
  margin-top: 30px;

  :deep(.el-form) {
    .el-select {
      width: initial;
      min-width:200px;
    }
  }
  .req-history {
    margin-top: 30px;
    &__item {
      margin-bottom: 22px
    }
  }
  
}
</style>